package com.yuhanginfo.modules.web.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.yuhanginfo.common.web.BaseController;
import com.yuhanginfo.modules.web.entity.WebYongUser;
import com.yuhanginfo.modules.web.service.WebYongUserService;

/**
 * 密码管理
 * @author yinhao
 * @version 2017-10-30
 */
@Controller
@RequestMapping(value = "${frontPath}/password")
public class WebPasswordController extends BaseController {

	@Autowired
	private WebYongUserService webYongUserService;
	
	@RequestMapping(value = "/forget")
	public String index() {
		return "modules/web/webPasswordFound";
	}

	@RequestMapping(value = "/toReset",method = RequestMethod.POST)
	public String check(String mobile,Model model) {
		model.addAttribute("mobile", mobile);
		return "modules/web/webPasswordReset";
	}
	
	@RequestMapping(value = "/reset",method = RequestMethod.POST)
	public String reset(WebYongUser user) {
		webYongUserService.updatePasswordByMobile(user);
		return "modules/web/webPasswordSuccess";
	}
}